<?php

require_once dirname(__FILE__) . '/Mailer.class.php';
require_once dirname(__FILE__) . '/smtp.class.php';

function post_email_by_smtp($title, $html, $to = array('think889977@sina.com')) {
    if (defined('OPEN_EMAIL_SMTP') && !OPEN_EMAIL_SMTP) {
        log::w('Limit By Const OPEN_EMAIL_SMTP,OPEN_EMAIL_SMTP is false,Not Send Email');
        return false;
    }
    $mail = new PHPMailer();

    $smtpserver = "smtp.sina.com";
    $smtpusermail = "kingphp@sina.com";
    $smtpusername = "kingphp@sina.com";
    $smtpuser = "kingphp@sina.com";
    $smtppass = "kingphp@123";

    $mailsubject = $title;
    $mailbody = $html;

    $mail->IsSMTP();        // send via SMTP
    $mail->Host = $smtpserver;   // SMTP servers
    $mail->SMTPAuth = true;     // turn on SMTP authentication
    $mail->Username = $smtpuser;   // SMTP username
    $mail->Password = $smtppass;   // SMTP password
    $mail->CharSet = "UTF-8";

    $mail->From = $smtpusermail;
    $mail->FromName = $smtpusername;

    if (is_array($to)) {
        foreach ($to as $t) {
            $mail->AddAddress($t);
        }
    } else {
        $mail->AddAddress($to);
    }

    $mail->WordWrap = 100; // set word wrap
    $mail->IsHTML(true); // send as HTML
    $mail->Subject = $mailsubject;
    $mail->Body = $mailbody;
    $mail->AltBody = $mailbody;
    return $mail->Send();
}

?>